//
//  health
//
//  Created by apple on 2021/11/9.
//  Copyright © 2021 zglee. All rights reserved.
//

#import "RecordDataBaseModel.h"
@implementation RecordDataBaseModel
//WCDB_IMPLEMENTATION(RecordDataBaseModel) //使用WCDB_IMPLEMENTATION宏在类文件定义绑定到数据库表的类。 该宏实现绑定到表
//
//WCDB_SYNTHESIZE(detectionId)
//WCDB_SYNTHESIZE(userId)
//WCDB_SYNTHESIZE(userName)
//WCDB_SYNTHESIZE(patientId)
//WCDB_SYNTHESIZE(patientName)
//WCDB_SYNTHESIZE(age)
//WCDB_SYNTHESIZE(gender)
//WCDB_SYNTHESIZE(detectionDateTime)
//WCDB_SYNTHESIZE(createDateTime)
//WCDB_SYNTHESIZE(period)
//WCDB_SYNTHESIZE(orgName)
//WCDB_SYNTHESIZE(unit)
//WCDB_PRIMARY(detectionId)

//- (void)encodeWithCoder:(NSCoder *)aCoder{
//    unsigned  int count = 0;
//    Ivar *ivars = class_copyIvarList(self.class, &count);
//    for (int i = 0; i < count; i++) {
//        const char *cname = ivar_getName(ivars[i]);
//        NSString *name = [NSString stringWithUTF8String:cname];
//        NSString *key = [name substringFromIndex:1];
//        id value = [self valueForKey:key];
//        [aCoder encodeObject:value forKey:key];
//    }
//}
//
//- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder{
//    if (self = [super init]) {
//        unsigned  int count = 0;
//        Ivar *ivars = class_copyIvarList(self.class, &count);
//        for (int i = 0; i < count; i++) {
//            const char *cname = ivar_getName(ivars[i]);
//            NSString *name = [NSString stringWithUTF8String:cname];
//            NSString *key = [name substringFromIndex:1];
//            id value = [aDecoder decodeObjectForKey:key];
//            [self setValue:value forKey:key];
//        }
//    }
//    return self;
//}

- (void)encodeWithCoder:(NSCoder *)aCoder {
    [self yy_modelEncodeWithCoder:aCoder];
}

- (instancetype)initWithCoder:(NSCoder *)aDecoder {
    self = [super init];
    return [self yy_modelInitWithCoder:aDecoder];
}


+ (BOOL)supportsSecureCoding {
    return YES;
}

//- (NSString *)periodString {
//    return [self.period isEqualToString:@"Fasting"]?@"空腹":@"餐后";
//}

- (BOOL)isFasting {
    return [self.period isEqualToString:@"Fasting"] ? true : false;
}
- (BOOL)isMale {
    return [self.gender isEqualToString:@"Male"] ? true : false;
}
#pragma mark -
- (NSString *)detectionDateTime {
    
    return _detectionDateTime ? _detectionDateTime : _createDateTime;
}


@end
